package com.emellend.api.buttons;

import com.emellend.api.R;

import android.app.Activity;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.ToggleButton;

public class Button2 extends Activity implements OnCheckedChangeListener {
	private ToggleButton mToggleButton;
	private ImageView mImageView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.buttons_2);
		init();
	}

	private void init() {
		mToggleButton = (ToggleButton) this.findViewById(R.id.toggle);
		mImageView = (ImageView) this.findViewById(R.id.img);
		setListener();
	}

	private void setListener() {
		mToggleButton.setOnCheckedChangeListener(this);
		
	}

	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		mToggleButton.setChecked(isChecked);
		mImageView.setImageResource(isChecked?R.drawable.light_on:R.drawable.light_off);
	}
}
